package ${sourceBasePackage}.controller<#if sourceIncludeModule == 'Y'>.${moduleName}</#if>;

import ${sourceBasePackage}.dto<#if sourceIncludeModule == 'Y'>.${moduleName}</#if>.${entityName}DTO;
import ${sourceBasePackage}.dto<#if sourceIncludeModule == 'Y'>.${moduleName}</#if>.${entityName}SearchDTO;
import ${sourceBasePackage}.model<#if sourceIncludeModule == 'Y'>.${moduleName}</#if>.${entityName};
import ${sourceBasePackage}.service<#if sourceIncludeModule == 'Y'>.${moduleName}</#if>.${entityName}Service;
import ${sourceBasePackage}.vo<#if sourceIncludeModule == 'Y'>.${moduleName}</#if>.${entityName}PageVO;

import com.jxdinfo.hussar.platform.core.base.apiresult.ApiResponse;
import com.jxdinfo.hussar.support.audit.core.annotations.AuditLog;
import com.jxdinfo.hussar.support.audit.core.enums.AuditEventGrade;
import com.jxdinfo.hussar.support.audit.core.enums.AuditEventType;
import com.jxdinfo.hussar.support.mp.base.controller.HussarBaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * ${description}控制类
 *
 * @author ${author}
 * @since ${createDate}
 */
@RestController(value = "${entityName}Controller")
@AuditLog(moduleName = "${description}")
@Api(tags="${description}API")
@RequestMapping(value = "/${entityName?uncap_first}/")
public class ${entityName}Controller {

	@Autowired
	private ${entityName}Service service;

    /**
     * 分页查询
     * @param ${entityName?uncap_first}SearchDTO
     * @return
     */
    @AuditLog(moduleName = "${description}", eventDesc = "列表查询", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @ApiOperation(value="列表查询")
    @PostMapping("listByPage")
	public ApiResponse<${entityName}PageVO> listByPage(@RequestBody ${entityName}SearchDTO ${entityName?uncap_first}SearchDTO) {
		return service.listByPage(${entityName?uncap_first}SearchDTO);
	}

    /**
     * 表单查询
     * @param ${pkPropertyName}
     * @return
     */
    @AuditLog(moduleName = "${description}", eventDesc = "表单查询", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.QUERY)
    @ApiOperation(value="表单查询")
    @GetMapping("getById")
    public ApiResponse<${entityName}DTO> getById(@RequestParam(value = "${pkPropertyName}") ${pkPropertyType} ${pkPropertyName}) {
        return service.getById(${pkPropertyName});
    }

    /**
     * 新增
     * @param ${entityName?uncap_first}DTO
     * @return
     */
    @AuditLog(moduleName = "${description}", eventDesc = "新增", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.INSERT)
    @ApiOperation(value="新增")
    @PostMapping("add")
    public ApiResponse<String> add(@RequestBody ${entityName}DTO ${entityName?uncap_first}DTO) {
        return service.add(${entityName?uncap_first}DTO);
    }

    /**
     * 修改
     * @param ${entityName?uncap_first}DTO
     * @return
     */
    @AuditLog(moduleName = "${description}", eventDesc = "修改", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.UPDATE)
    @ApiOperation(value="修改")
    @PostMapping("update")
    public ApiResponse<String> update(@RequestBody ${entityName}DTO ${entityName?uncap_first}DTO) {
        return service.update(${entityName?uncap_first}DTO);
    }

    /**
     * 删除
     * @param ${pkPropertyName}
     * @return
     */
    @AuditLog(moduleName = "${description}", eventDesc = "删除", eventGrade = AuditEventGrade.SERVICE_LOG_TYPE, evnetType = AuditEventType.DELETE)
    @ApiOperation(value="删除")
    @GetMapping("del")
    public ApiResponse<Boolean> del(@RequestParam(value = "${pkPropertyName}") ${pkPropertyType} ${pkPropertyName}) {
        return service.delete(${pkPropertyName});
    }

}
